package com.asistencia.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.asistencia.businness.CareerBusiness;
import com.asistencia.businness.SemesterBusiness;
import com.asistencia.businness.StudentBusiness;
import com.asistencia.domain.Student;

@Controller
public class StudentController {
	@Autowired
	private StudentBusiness studentBusiness;
	private Student student;
	@Autowired
	private SemesterBusiness semesterBusiness;
	private CareerBusiness careerBusiness;

	@RequestMapping(value = "/student-index.tecsup", method = RequestMethod.GET)
	public String buscarPorNombre(ModelMap modelMap,
			@RequestParam(value = "student") String name) {
		List<Student> lstStudent = studentBusiness.listByName(name);
		if (lstStudent != null){
			for(Student al:lstStudent){
				al.setMyCareer(careerBusiness.getById(al.getMyCareer().getIdCareer()));
			}
			modelMap.addAttribute("lstStudent", lstStudent);
			return "student";
		}
		return name;
	}
	@RequestMapping(value ="/student.tecsup", method = RequestMethod.GET)
	public String buscarStudent(){
		return "student";
		
	}
}
